package com.fannm.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.google.common.base.Predicates;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * swagger文档
 * 
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
	//JAVA学习接口文档
	public static final String JAVA_STUDY = "com.fannm.controller.javaStudy";
	//JPA学习接口文档
	public static final String JPA_STUDY = "com.fannm.controller.jpaStudy";

	@Bean
	public Docket javaStudyApi() {
		return new Docket(DocumentationType.SWAGGER_2).groupName("java_study_api")
				.apiInfo(new ApiInfoBuilder().title("JAVA学习接口文档")
				.version("1.0").build())
				.select().paths(PathSelectors.any())
				.apis(RequestHandlerSelectors.basePackage(JAVA_STUDY))//api接口包扫描路径
				.paths(Predicates.not(PathSelectors.regex("/error.*")))// 错误路径不监控
				.build();
	}

	@Bean
	public Docket jpaStudyApi() {
		return new Docket(DocumentationType.SWAGGER_2).groupName("jpa-study-api")
				.apiInfo(new ApiInfoBuilder().title("JPA学习接口文档")
						.version("1.0").build())
				.select().paths(PathSelectors.any())
				.apis(RequestHandlerSelectors.basePackage(JPA_STUDY))//api接口包扫描路径
				.paths(Predicates.not(PathSelectors.regex("/error.*")))// 错误路径不监控
				.build();
	}


}
